Skip to content

fix(validator): check #anchor fragments on references/ links - #626

Merged
addyosmani merged 1 commit into
addyosmani:mainfrom
nucliweb:fix/reference-links-anchors
Oct 3, 2026
Merged

addyosmani merged 1 commit into
addyosmani:mainfrom
nucliweb:fix/reference-links-anchors

Conversation

@nucliweb

@nucliweb nucliweb commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

Closes #625.

What

validate-reference-links.js also resolves the #fragment after a references/*.md link: it slugs the target file's headings the way GitHub does and fails when none matches. Same rule and scope as before; only links the validator already matched gain the check, and only when their file exists, so a missing file is still reported once.

Slugs follow GitHub's rules, as asked in #625: the rendered heading text (link text kept, emphasis and code spans unwrapped), lowercased, punctuation other than - and _ dropped, spaces to hyphens, and -1, -2 for repeated headings. Headings inside fenced blocks don't count; the bash comments in accessibility-checklist.md (# Chrome DevTools → Lighthouse → Accessibility) would otherwise read as H1s. The path hint only prints when a path is wrong, and anchor failures get their own hint.

Verification

Check Result
node --test scripts/validate-reference-links-test.js 28/28 (21 existing + 7 new; 4 of the new ones failed before the change, the other 3 guard against false positives)
Slugs against GitHub's own anchors (contents API with application/vnd.github.html, at 9d0c60d) 145/145 identical across the 9 reference files
Duplicate headings against GitHub: skills/idea-refine/examples.md has three "Phase 1: Understand & Expand" GitHub gives phase-1-understand--expand, -1, -2; 17/17 identical
Validator on 9d0c60d 25 skills, the 17 existing anchors resolve, exit 0
Mutation: #rate-limiting (SKILL.md L125) and #destructive-path-operations (hardening-patterns.md L208) renamed 2 errors with the anchor hint and no path hint, exit 1
Mutation: ### Injection renamed to ### Injection attacks this branch reports SKILL.md L85, exit 1; upstream main passes
validate-skills, -commands, -artifact-paths, -versions, the other scripts/*-test.js, run-evals.js, session-start-test.sh pass

Coordination

A correction to #625: of the 14 anchors #621 adds, 12 are same-file links inside review-checklists.md, which stay out of scope; the other 2 are references/ links from SKILL.md, and both resolve with this check. #524 also touches the test file; these tests are appended as a block, as in #588.

Out of scope, as agreed in #625: same-file #anchor links, links outside references/ and HTML id anchors. Setext headings aren't slugged either; none of the reference files use them.

@addyosmani addyosmani left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: exactly the shape I hoped for on #625: same rule, same scope, it just stops a heading rename from breaking links silently. It passes on today's main with all 26 anchors in scope, including the ones #580 added an hour ago, and when I broke one it failed naming the line and the missing slug. The tests cover the GitHub slug cases that matter (the -1 duplicate, rendered text, fenced headings). Merging.

@addyosmani
addyosmani merged commit 0dafdcc into addyosmani:main Oct 3, 2026
7 checks passed
hillemacher pushed a commit to hillemacher/agent-skills that referenced this pull request Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

validate-reference-links doesn't check #anchor fragments

2 participants